package de.v1rus777.bukkit;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

public class TestPlugin extends JavaPlugin 
{
		
	@Override
	public void onEnable() 
	{
		PluginManager pm = this.getServer().getPluginManager();
		
		TestPluginListener listener = new TestPluginListener();	
		pm.registerEvents(listener, this);
	}
	
	@Override
	public void onDisable() 
	{
	
	}
	
	@Override
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) 
	{
		if (command.getName().equalsIgnoreCase("rvp"))
		{
			if (sender instanceof Player)
			{
				Player player = (Player)sender;
							
				int x = 1;
				if (args.length == 1)
				{
					x = Integer.parseInt(args[0]);
				}
				
				for (int i=0; i < Math.min(x, 50);  i++)
				{
					player.getWorld().spawnEntity(player.getLocation(), EntityType.BAT);
				}	
			}
			
			return true;
		}
		else
			return super.onCommand(sender, command, label, args);
	}
	
}
